package com.topvision.myviewtest.recycler.itemdecoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.topvision.myviewtest.R;

/**
 * @author lucy
 * @date 2018-03-28 15:05
 * @description //TODO
 */

public class PaddingDecoration extends RecyclerView.ItemDecoration {

    private final int mPadding;

    public PaddingDecoration(Context context) {
        // 设置分割线宽度
        mPadding = context.getResources().getDimensionPixelSize(R.dimen.item_decoration_padding);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        // 设置上下左右padding值
        outRect.left = mPadding;
        outRect.top = mPadding;
        outRect.right = mPadding;
        outRect.bottom = mPadding;
    }
}
